package com.johnny.action;

import java.net.Socket;

import net.sf.json.JSONObject;

public class ActionDispatch {
	public static String Dispatch(String str,Socket socket) {
		JSONObject object=JSONObject.fromObject(str);
		String actionStr=object.getString("action");
		try {
			Class<Action> clazz=(Class<Action>) Class.forName("com.johnny.action."+actionStr+"Action");
			Action action=clazz.newInstance();
			return action.doAction(object,socket);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		return null;
	}
}
